{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 6,
   "id": "183eb934",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "250"
      ]
     },
     "execution_count": 6,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "wages = {'铁蛋': 250, '王三贵': 666, '王二狗': 888}\n",
    "wages['铁蛋']"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 11,
   "id": "5f187251",
   "metadata": {},
   "outputs": [],
   "source": [
    "wages['阿牛']=222"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 13,
   "id": "3fa40d40",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "222"
      ]
     },
     "execution_count": 13,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "wages['阿牛']"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 14,
   "id": "bf212e90",
   "metadata": {},
   "outputs": [],
   "source": [
    "del wages['铁蛋']\n",
    "# del 用来删除wages字典里面指定的信息"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 15,
   "id": "4d4d8afb",
   "metadata": {
    "scrolled": true
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "{'王三贵': 666, '王二狗': 888, '阿牛': 222}"
      ]
     },
     "execution_count": 15,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "wages"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 18,
   "id": "aa9f2c96",
   "metadata": {},
   "outputs": [],
   "source": [
    "# 因为铁蛋被删除了，如果正常输出字典名称的时候，会报错，但是如果你用get的话可以避免这个问题，如下所示：\n",
    "wages.get(\"铁蛋\")"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "21f92812",
   "metadata": {},
   "source": [
    "# 字典的遍历——计算工资的发放"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 41,
   "id": "eb4de097",
   "metadata": {},
   "outputs": [],
   "source": [
    "salary = {'流氓':1200,'斯文':1100,'江老板':1000}\n",
    "workday = {'流氓':5,'斯文':6,'江老板':7}"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 44,
   "id": "7114496b",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "6000\n",
      "6600\n",
      "7000\n",
      "总支付工资为： 19600\n"
     ]
    }
   ],
   "source": [
    "paid = 0\n",
    "for i in salary:\n",
    "    print(salary[i]*workday[i])\n",
    "    paid = paid + (salary[i]*workday[i])\n",
    "print('总支付工资为：', paid)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "cb47b482",
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.8.8"
  },
  "toc": {
   "base_numbering": 1,
   "nav_menu": {},
   "number_sections": true,
   "sideBar": true,
   "skip_h1_title": false,
   "title_cell": "Table of Contents",
   "title_sidebar": "Contents",
   "toc_cell": false,
   "toc_position": {},
   "toc_section_display": true,
   "toc_window_display": false
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
